<template>
  <div>
    <!-- 系统参数维护--车厂 -->
    <TopFilter ref="TopFilterss" :list="topFilterInit" :cols="3" :collapse="collapse" labelWidth="90" @filterChange="changeHandle"></TopFilter>
    <!-- table -->
    <FilterTable
      ref="table"
      :columns="columns"
      :params="fetchParams"
     :fetchapi="fetchapi"
      :datakey="'records'"
      :onColumnsChange="columns => (this.columns = columns)"
      :onRowSelectChange="selectChange"
      :is-select-column="false"
    >
    </FilterTable>
    <BaseDialog :visible.sync="emitVisible" title="索赔参数编辑"  width="850px" destroyOnClose :containerStyle="{ height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px' }">
      <editForm @close="emitCloseHandle" @addChange="emitChange" :rowData="rowData" />
    </BaseDialog>
  </div>
</template>
<script>
// import AddForm from './AddForm.vue';
import editForm from './editForm.vue';
import { getListByPage, newSave, piliangqiyong, piliangtingyong, excelExport, editSave } from '@/api/claim/factory/SystemParameterMaintain';
export default {
  //  mixins: [dictionary],
  components: {
    // AddForm,
    editForm
  },
  data() {
    return {
      dataList: [],
      visible: false,
      visibleDrawer: false,
      collapse: false,
      emitVisible: false,
      infoId: null,
      rowData: {},
      fetchapi: getListByPage,
      topFilterInit: this.topFilterInitFun(),
      flterValue: {}, //参数
      columns: this.creatHeader(),
      fetchParams: {}, //ipa 接口
      selectedRows: [], //选中经销商
      dialogTitle: '选择车辆',
      visibleAdd: false
    };
  },
  created() {

  },
  methods: {
    //选中
    selectChange(rows) {
      this.selectedRows = rows;
      console.log(this.selectedRows);
    },
    // close(){
    //   this.visible = false;
    // },
    // chooseOrderNo() {
    //   this.visible = true;
    // },
    // save(obj) {
    //   this.topFilterInit.find(x => x.fieldName == 'model').initialValue = obj[0].address;
    //   this.visible = false;
    // },
    exportFileBtn() {
      this.$refs.TopFilterss.SUBMIT_FORM();
    },
    add() {
      this.visibleAdd = true;
    },
    emitFun(val) {
      this.rowData = val;
      this.emitVisible = true;
    },
    emitCloseHandle() {
      this.emitVisible = false;
    },
    emitChange() {
      this.emitVisible = false;
      this.fetchParams = { ...this.fetchParams };
    },
    closeAdd() {
      this.visibleAdd = false;
      this.fetchParams = { ...this.fetchParams };
    },
    saveAdd() {
      this.visibleAdd = false;
      this.fetchParams = { ...this.fetchParams };
    },
    //搜索获取数据
    changeHandle(val) {
      this.fetchParams = Object.assign({}, this.fetchParams, val);
      console.log(val);
    },
    //搜索数据
    topFilterInitFun() {
      return [
        { type: 'INPUT', label: '参数代码', fieldName: 'paraCode', placeholder: '请输入参数代码...', initialValue: '' },
        { type: 'INPUT', label: '参数描述', fieldName: 'paraRemarks', placeholder: '请输入参数描述...', initialValue: '' }
        // { type: 'INPUT', label: '业务模块', fieldName: 'busModel', placeholder: '请输入业务模块...', initialValue: '' }
      ];
    },

    //table表头和数据源
    creatHeader() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 80,
          fixed: 'left',
          sorter: true,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        {
          title: '操作',
          dataIndex: 'column-action',
          width: 80,
          render: (props, h) => {
            return (
              <div style="text-align:center">
                <multiuse-button size="mini" type="text" onClick={() => this.emitFun(props.row)}>
                  编辑
                </multiuse-button>
              </div>
            );
          }
        },
        // { title: '业务模块', dataIndex: 'busModel', sorter: true },
        { title: '参数代码', dataIndex: 'paraCode', sorter: true },
        { title: '参数描述', dataIndex: 'paraRemarks', sorter: true},
        { title: '参数值', dataIndex: 'para', sorter: true },
        { title: '修改人', dataIndex: 'updatedBy', sorter: true },
        { title: '修改时间', dataIndex: 'updatedAt', sorter: true },
        // { title: '参数值2', dataIndex: 'para2', sorter: true, },
        // { title: '参数值3', dataIndex: 'para3', sorter: true },
        // { title: '参数值4', dataIndex: 'para4', sorter: true },
      ];
    }
  }
  // mounted() {
  //   this.BaseTable = this.$refs.listModal.$refs.pageTable;
  // }
};
</script>

<style lang="less" scoped></style>
